package com.novel.common.vo;

import com.novel.common.enums.BeAuthorStatusEnum;
import com.novel.pojo.system.ApplyAuthor;
import lombok.Data;

import java.util.Date;

@Data
public class ApplyAuthorVo {

    private String id;//主键id
    private String userEmail;//用户邮箱
    private String status;//状态
    private Date createdTime;//创建时间
    private String reason;//理由


    public static ApplyAuthorVo convert(ApplyAuthor applyAuthor) {
        ApplyAuthorVo vo = new ApplyAuthorVo();
        vo.setId(applyAuthor.getId());
        vo.setUserEmail(applyAuthor.getUserEmail());

        if (applyAuthor.getStatus() == BeAuthorStatusEnum.CANCEL.getCode()) {
            vo.setStatus(BeAuthorStatusEnum.CANCEL.getDesc());
        } else if (applyAuthor.getStatus() == BeAuthorStatusEnum.WAIT.getCode()) {
            vo.setStatus(BeAuthorStatusEnum.WAIT.getDesc());
        } else if (applyAuthor.getStatus() == BeAuthorStatusEnum.PASS.getCode()) {
            vo.setStatus(BeAuthorStatusEnum.PASS.getDesc());
        } else if (applyAuthor.getStatus() == BeAuthorStatusEnum.REJECT.getCode()) {
            vo.setStatus(BeAuthorStatusEnum.REJECT.getDesc());
        }

        vo.setCreatedTime(applyAuthor.getCreatedTime());
        vo.setReason(applyAuthor.getReason());
        return vo;
    }

}